<div ng-controller="orderMyDetailC">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">我的计划单详情---
            <span ng-if="orderdetaildata.OrderType == 0">普通订单</span>
            <span ng-if="orderdetaildata.OrderType == 1">商品锁价</span>
            <span ng-if="orderdetaildata.OrderType == 2">基价锁价</span>
            <span ng-if="orderdetaildata.OrderType == 3">自采订单</span>
            <span ng-if="orderdetaildata.OrderType == 4">库提销售</span>
        </h1>
    </div>
    <div class="modal fade" id="tupian" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <!--<h4 class="modal-title" id="myModalLabe3">收货凭证 </h4>-->
                <!--<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>-->
                <img style="width: 100%;" ng-src="/file/{{editReceiptdata}}" alt="收货凭证">
            </div>
        </div>
    </div>
    <div class="modal fade" id="shangchuan" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <form id="myupload" action={{myurl}} method="post" enctype="multipart/form-data">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabe2">上传收货凭证 </h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group btn">
                            <!--<input type="label" name="label" id="label" class="form-control" placeholder="请选择文件" /><br />-->
                            <label style="margin-right: 10px;">请选择文件</label>
                            <input type="file" name="file1" id="fileupload" class="form-control" value="" /><br />
                        </div>
                        <div class="progress">
                            <span class="bar"></span><span class="percent">0%</span>
                        </div>
                        <!-- 显示已上传的文件名 -->
                        <div class="files"></div>
                        <!-- 显示已上传的图片-->
                        <div class="showimg"></div>
                    </div>
                    <div class="modal-footer">
                        <!--<button type="button" class="btn btn-success" ng-disabled="myform1.$invalid" ng-click="okchange()">确认提交</button>-->
                        <input type="button" class="btn btn-default" ng-click="gosubmit2()" value="提交" />
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="modal fade" id="baokuan" tabindex="-1" role="dialog" aria-labelledby="ModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <form name="myform" class="form-validation">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="ModalLabel">新建报款</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="control-label">客户：{{orderdetaildata.Customer.Name}}--户头：{{orderdetaildata.Account.Name}}</label>
                        </div>
                        <div class="form-group">
                            <label class="control-label">金额</label>
                            <input required type="number" class="form-control" ng-model="NowData.Sum">
                        </div>
                        <div ng-if="orderdetaildata.Account.IsCash" class="form-group">
                            <label class="control-label">备注(必填)</label>
                            <input required type="text" class="form-control" ng-model="NowData.Remark" placeholder="请输入打卡账户后四位">
                        </div>
                        <div ng-if="!orderdetaildata.Account.IsCash" class="form-group">
                            <label class="control-label">备注(选填)</label>
                            <input type="text" class="form-control" ng-model="NowData.Remark" placeholder="请输入打卡账户后四位">
                        </div>
                        <div class="form-group">
                            <label>收款账户</label>
                            <select required class="form-control" ng-model="NowData.ToAccount">
                                <option value="公-交行西苑路支行">公-交行西苑路支行</option>
                                <option value="公-工行洛南支行">公-工行洛南支行</option>
                                <option value="公-洛阳银行洛龙区支行">公-洛阳银行洛龙区支行</option>
                                <option value="公-伊川农商行人民路支行">公-伊川农商行人民路支行</option>
                                <option value="公-北京沐威中行">公-北京沐威中行</option>
                                <option value="中国农业银行洛阳中泓支行">中国农业银行洛阳中泓支行</option>
                                <option value="中国工商银行洛阳政和支行">中国工商银行洛阳政和支行</option>
                                <option value="中国建设银行洛阳开元大道支行">中国建设银行洛阳开元大道支行</option>
                                <option value="中国银行洛阳政和路支行">中国银行洛阳政和路支行</option>
                                <option value="交通银行洛阳分行营业部">交通银行洛阳分行营业部</option>
                                <option value="洛阳农商行金城寨街支行">洛阳农商行金城寨街支行</option>
                                <option value="中信银行洛阳联盟路支行">中信银行洛阳联盟路支行</option>
                                <option value="兴业银行洛阳凯旋东路支行">兴业银行洛阳凯旋东路支行</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label">付款时间</label>
                            <input required type="datetime-local" class="form-control" ng-model="NowData.CreateTime">
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-success" ng-disabled="myform.$invalid" ng-click="add()">确认报备</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="wrapper-md">
        <div class="panel panel-default">
            <div class="table-responsive">
                <form name="form" class="form-validation">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div class="form-group">
                                <label>客户</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Customer.Name}}">
                            </div>
                            <div class="form-group">
                                <label>公司户头</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Account.Name}}">
                            </div>
                            <div class="form-group">
                                <label>区域</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.District.FillName}}">
                            </div>
                            <div class="form-group">
                                <label>客户经理</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Creater.Name}}">
                            </div>
                            <div class="form-group">
                                <label>创建时间</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.CreateTime}}">
                            </div>
                            <div class="form-group" ng-if='orderdetaildata.IsDelivery!=1'>
                                <label>具体地址</label>
                                <input type="text" ng-disabled="readonlytoggel"  class="form-control" ng-model="orderdetaildata.Address">
                            </div>
                            <div class="form-group">
                                <label for="xiankuan" style="margin-right: 10px;">是否先款</label>
                                <label class="i-checks">
                                    <input type="checkbox" id="xiankuan" disabled="disabled" ng-model="orderdetaildata.IsFullPayment">
                                    <i></i>
                                </label>
                                <label for="suojia" style="margin-right: 10px;">是否锁价</label>
                                <label class="i-checks">
                                    <input type="checkbox" id="suojia" disabled="disabled" ng-model="orderdetaildata.IsLockPrice">
                                    <i></i>
                                </label>
                            </div>
                            <!--<div class="form-group">-->
                                <!--<label for="suojia" style="margin-right: 10px;">是否锁价</label>-->
                                <!--<label class="i-checks">-->
                                    <!--<input type="checkbox" id="suojia" disabled="disabled" ng-model="orderdetaildata.IsLockPrice">-->
                                    <!--<i></i>-->
                                <!--</label>-->
                            <!--</div>-->
                            <div class="form-group">
                                <label for="biaojian" style="margin-right: 10px;">是否标件</label>
                                <label class="i-checks">
                                    <input type="checkbox" id="biaojian" disabled="disabled" ng-model="orderdetaildata.IsStandard">
                                    <i></i>
                                </label>
                                <label for="zipai" style="margin-right: 10px;">是否自派</label>
                                <label class="i-checks">
                                    <input type="checkbox" id="zipai" disabled="disabled" ng-model="orderdetaildata.IsDelivery">
                                    <i></i>
                                </label>
                            </div>
                            <!--<div class="form-group">-->
                                <!--<label for="zipai" style="margin-right: 10px;">是否自派</label>-->
                                <!--<label class="i-checks">-->
                                    <!--<input type="checkbox" id="zipai" disabled="disabled" ng-model="orderdetaildata.IsDelivery">-->
                                    <!--<i></i>-->
                                <!--</label>-->
                            <!--</div>-->
                            <div class="form-group" ng-if="!(orderdetaildata.IsDelivery || orderdetaildata.Account.IsCash)">
                                <label style="margin-right: 10px;">运费是否公户</label>
                                <label class="i-checks">
                                    <input type="checkbox" disabled="disabled" ng-model="orderdetaildata.IsPublicDelivery">
                                    <i></i>
                                </label>
                            </div>
                            <div class="form-group" ng-if="!orderdetaildata.IsDelivery">
                                <label>每吨运费</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.DeliveryPrice}}">
                            </div>
                            <div class="form-group" ng-if="(orderdetaildata.IsDelivery ||orderdetaildata.VehicleInfos!=null)">
                                <label>车辆信息</label>
                                <input type="text" class="form-control" ng-disabled="readonlytoggel" ng-model="orderdetaildata.VehicleInfos">
                            </div>
                            <div class="form-group" ng-if="(orderdetaildata.IsDelivery ||orderdetaildata.Contact!=null)">
                                <label>联系人</label>
                                <input type="text" class="form-control" ng-disabled="readonlytoggel" ng-model="orderdetaildata.Contact">
                            </div>
                            <div class="form-group" ng-if="(orderdetaildata.IsDelivery ||orderdetaildata.ContactPhone!=null)">
                                <label>联系人手机号</label>
                                <input type="text" class="form-control" ng-disabled="readonlytoggel" ng-model="orderdetaildata.ContactPhone">
                            </div>
                            <div class="form-group">
                                <label>备注</label>
                                <input type="text" class="form-control" ng-disabled="readonlytoggel" ng-model="orderdetaildata.Remarks">
                            </div>
                            <div class="form-group">
                                <label>申请单价优惠</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.ApplyDiscount}}">
                            </div>
                            <!--<div class="form-group">-->
                                <!--<label>申请总价优惠</label>-->
                                <!--<input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.BargainingAmount}}">-->
                            <!--</div>-->
                            <div class="form-group">
                                <label ng-if="orderdetaildata.Provider.ProviderType == 0">钢厂</label>
                                <label ng-if="orderdetaildata.Provider.ProviderType == 1">仓库</label>
                                <label ng-if="orderdetaildata.Provider.ProviderType == 2">贸易商</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Provider.Name}}">
                            </div>
                            <!--<div class="form-group">-->
                                <!--<label>变更记录</label>-->
                                <!--<ul>-->
                                    <!--<li ng-repeat="item in orderdetaildata.Records | orderBy:['CreateTime']">-->
                                        <!--{{item.CreateTime}}/<label ng-if="item.Price != 0">{{item.Price}}/</label>{{item.Remarks}}-->
                                    <!--</li>-->
                                <!--</ul>-->
                            <!--</div>-->
                            <div class="form-group">
                                <accordion close-others="oneAtATime">
                                    <accordion-group heading="查看历史记录➤">
                                        <ul>
                                            <li ng-repeat="item in orderdetaildata.Records | orderBy:['CreateTime']">
                                                {{item.CreateTime}}/<label ng-if="item.Price != 0">{{item.Price | number:2}}/</label>{{item.Remarks}}
                                            </li>
                                            <li style="color:red;">
                                                该户头余额:{{orderdetaildata.Account.Amount | number:2}}￥
                                            </li>
                                        </ul>
                                    </accordion-group>
                                </accordion>
                            </div>
                            <div class="form-group">
                                <label>已付金额：</label>
                                <span>{{orderdetaildata.Prepayments | number:2}}</span>
                            </div>
                            <div ng-if="orderdetaildata.Prepayments >= orderdetaildata.Total " class="form-group">
                                <label>计划单已付清</label>
                            </div>
                            <div ng-if="orderdetaildata.Prepayments < orderdetaildata.Total && orderdetaildata.State != 6 " class="form-group">
                                <label style="color: red">计划单未付清</label>
                            </div>
                            <!--<div class="form-group">-->
                                <!--<label>已付运费：</label>-->
                                <!--<span>{{orderdetaildata.PaidDelivery | number:2}}</span>-->
                            <!--</div>-->
                            <div ng-if="orderdetaildata.PaidDelivery >= orderdetaildata.DeliveryPriceTotal&& orderdetaildata.State != 6 " class="form-group">
                                <label>运费已付</label>
                            </div>
                            <div ng-if="orderdetaildata.PaidDelivery < orderdetaildata.DeliveryPriceTotal && orderdetaildata.State != 6 " class="form-group">
                                <label style="color: red">运费未付</label>
                            </div>

                            <div class="form-group" ng-if="orderdetaildata.Prepayments+orderdetaildata.PaidDelivery < orderdetaildata.DeliveryPriceTotal+orderdetaildata.Total">
                                <button type="button" class="btn btn-success" data-toggle="modal" data-target="#baokuan" ng-if="orderdetaildata.State!=6">新建报款</button>
                            </div>
                            <div class="form-group">
                                <label>订单状态：</label>
                                <span style="width:10%" ng-if="orderdetaildata.State == 0">待确认</span>
                                <span style="width:10%" ng-if="orderdetaildata.State == 1">驻厂确认</span>
                                <span style="width:10%" ng-if="orderdetaildata.State == 2">已发货</span>
                                <span style="width:10%" ng-if="orderdetaildata.State == 3">已收货</span>
                                <span style="width:10%" ng-if="orderdetaildata.State == 4">已结算</span>
                                <span style="width:10%" ng-if="orderdetaildata.State == 5">完结</span>
                                <span style="width:10%" ng-if="orderdetaildata.State == 6">取消</span>
                                <span style="width:10%" ng-if="orderdetaildata.State == 7">审核通过</span>
                                <span style="width:10%" ng-if="orderdetaildata.State == 8">已退货</span>
                                <span style="width:10%" ng-if="orderdetaildata.State == 9">已退款</span>
                            </div>
                            <div class="form-group">
                                <label>流程状态：</label>
                                <span style="width:10%" ng-if="orderdetaildata.ProcessState == 0">正常</span>
                                <span style="width:10%" ng-if="orderdetaildata.ProcessState == 1">议价</span>
                                <span style="width:10%" ng-if="orderdetaildata.ProcessState == 2">锁价</span>
                                <span style="width:10%" ng-if="orderdetaildata.ProcessState == 3">款项确认</span>
                                <span style="width:10%" ng-if="orderdetaildata.ProcessState == 4">审核通过</span>
                            </div>
                            <div class="form-group" ng-if="GetReceiptdata">
                                <label>收货凭证：</label>
                                <img style="height: 50px; margin: 10px" ng-repeat="item in GetReceiptdata track by $index" ng-src="/file/{{item}}" alt="收货凭证" ng-click="editReceipt(item)" data-toggle="modal" data-target="#tupian">
                            </div>
                            <div class="form-group">
                                <label>订单ID：</label>
                                <span>{{orderdetaildata.Id}}</span>
                            </div>
                        </div>
                        <div class="container-fluid text-center bg-light lter" >
                            <div class="row">
                                <h3 style="display: inline-block;margin: 0 auto">订单商品列表</h3>
                            </div>
                        </div>
                        <div class="container-fluid" style="padding-top: 10px">
                            <!--<div class="row" style="border-bottom: red solid 1px" ng-repeat="item in orderdetaildata.CommodityInfos">-->
                                <!--<div class="col-xs-12 col-md-12">-->
                                    <!--<div>钢厂：{{item.Commodity.Brand}}</div>-->
                                    <!--<div>名称/材质/规格：{{item.Commodity.Name}}/{{item.Commodity.Standard}}/{{item.Commodity.Format}}</div>-->
                                    <!--<div>单价：{{item.Price | number:2}}/t</div>-->
                                    <!--<div>数量：{{item.Count}}</div>-->
                                    <!--<div>总质量：{{item.Weight | number:3}}t</div>-->
                                    <!--<div>总价：{{item.Price | number:2}}*{{item.Weight | number:3}}t={{item.Price*item.Weight | number:2}}</div>-->
                                <!--</div>-->
                            <!--</div>-->


                            <div class="panel panel-default" ng-repeat="item in orderdetaildata.CommodityInfos" style="margin-bottom: 10px">
                                <div class="panel-heading">
                                    <div>品牌：{{item.Commodity.Brand}}</div>
                                </div>
                                <div class="panel-body">
                                    <div class="row">
                                        <div class="col-xs-12 col-md-12">
                                            <div>名称/材质/规格：{{item.Commodity.Name}}/{{item.Commodity.Standard}}/{{item.Commodity.Format}}</div>
                                            <div>单价：{{item.Price | number:2}}/t</div>
                                            <div>数量：{{item.Count | number:2}}</div>
                                            <div>总质量：{{item.Weight | number:3}}t</div>
                                        </div>
                                    </div>
                                </div>
                                <div class="panel-footer">
                                    <div>总价：{{item.Price | number:2}}*{{item.Weight | number:3}}t={{item.Price*item.Weight | number:2}}</div>
                                </div>
                            </div>
                            <div class="row text-left container-fluid" ng-if="((orderdetaildata.Provider.IsNonStandard==1?orderdetaildata.Provider.NonstandardDiscount:0)+(orderdetaildata.IsFullPayment==1?orderdetaildata.Provider.FullPaymentDiscount:0) | number:2)*orderdetaildata.Weight | number:2 > 0">
                                <span>先款/非标优惠合计：{{((orderdetaildata.IsStandard==0?orderdetaildata.Provider.NonstandardDiscount:0)+(orderdetaildata.IsFullPayment==1?orderdetaildata.Provider.FullPaymentDiscount:0) | number:2)*orderdetaildata.Weight | number:2}}</span>
                            </div>
                            <!--<div class="row text-left container-fluid" ng-if="orderdetaildata.NonstandardDiscount > 0">-->
                                <!--<span>非标优惠：{{orderdetaildata.NonstandardDiscount | number:2}}</span>-->
                            <!--</div>-->
                            <div class="row text-left container-fluid" ng-if="orderdetaildata.ApplyDiscount > 0">
                                <span>单价优惠合计：{{orderdetaildata.ApplyDiscount*orderdetaildata.Weight | number:2}}</span>
                            </div>
                            <div class="row text-left container-fluid">
                                <h4 style="display: inline-block">总价：{{orderdetaildata.Total | number:2}}</h4>
                            </div>
                            <div class="row text-left container-fluid">
                                <h4 style="display: inline-block">运费：{{orderdetaildata.DeliveryPriceTotal | number:2}}</h4>
                            </div>
                            <div class="row text-right">
                                <button ng-if="orderdetaildata.State == 2 || orderdetaildata.State == 3 || orderdetaildata.State == 4 || orderdetaildata.State == 5" type="button" class="btn btn-danger" data-toggle="modal" data-target="#shangchuan">上传收货凭证</button>
                                <button ng-if="(orderdetaildata.State != 1 && orderdetaildata.State != 2 && (orderdetaildata.ApplyDiscount==0 || orderdetaildata.IsLockPrice!=1) && orderdetaildata.IsSettlement != 1 && orderdetaildata.State != 0)||orderdetaildata.State == 7&&((orderdetaildata.IsFullPayment==1 || orderdetaildata.IsLockPrice==1)&& orderdetaildata.State != 2)    ||   (orderdetaildata.State == 0 && (orderdetaildata.ApplyDiscount== 0 && orderdetaildata.IsLockPrice!=1))" type="button" class="btn btn-danger" ng-disabled="!readonlytoggel" ng-click="cancel()">取消计划单</button>
                                <!--<button ng-if="orderdetaildata.State == 2 || orderdetaildata.State == 3" type="button" class="btn btn-danger" ng-click="refunds()">申请退货</button>-->
                                <button ng-if="readonlytoggel==true"  class="btn btn-success" ng-click="ipttoggel()">{{orderdetaildata.IsDelivery==1?'修改车辆信息':'修改地址'}}</button>
                                <button ng-if="readonlytoggel!=true"  class="btn btn-success" ng-click="savechage()">{{orderdetaildata.IsDelivery==1?'保存车辆信息':'保存地址'}}</button>
                                <button ng-if="(orderdetaildata.State != 6 && orderdetaildata.State != 8 && orderdetaildata.State != 9 && orderdetaildata.ProcessState != 1 && orderdetaildata.ProcessState != 2) || ((orderdetaildata.ProcessState == 1 || orderdetaildata.ProcessState == 2) && orderdetaildata.State == 7)&&readonlytoggel==true" ng-disabled="!readonlytoggel" type="button" class="btn btn-success" ng-click="printPact()">打印物联合同</button>
                                <button ng-if="(orderdetaildata.State != 6 && orderdetaildata.State != 8 && orderdetaildata.State != 9 && orderdetaildata.ProcessState != 1 && orderdetaildata.ProcessState != 2) || ((orderdetaildata.ProcessState == 1 || orderdetaildata.ProcessState == 2) && orderdetaildata.State == 7)" type="button" class="btn btn-success" ng-disabled="!readonlytoggel" ng-click="printPactMW()">打印沐威合同</button>
                                <button ng-if="orderdetaildata.State == 1" ng-disabled="!readonlytoggel" type="button" class="btn btn-success" ng-click="printOut()">打印提货单</button>
                                <button type="button" ng-disabled="!readonlytoggel"  class="btn btn-success" ng-click="goorderList()">返回计划单列表</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    angular.module('app')
        //计划单详情控制器
    .controller("orderMyDetailC", function ($scope, $state, $stateParams, $http) {
        $scope.NowData = {
            Customer:{},
            AccountId:"",
            CreateTime: new Date(new Date().format("yyyy-MM-dd hh:mm:ss"))
        };
        $scope.AllPrice=[]
        $scope.sprice=0;
        $scope.id = JSON.parse($stateParams.orderid);
        $scope.myurl = '../api/Upload?orderId='+$scope.id;
        //获取计划单详细数据
        $http({
            url: "../api/Order/Detail?id=" + $scope.id,
            method: "GET"
        })
            .then(function (res) {
                debugger;
                $scope.orderdetaildata = res.data;
                console.log($scope.orderdetaildata);
              // for (var i = 0; i < $scope.orderdetaildata.CommodityInfos.length; i++) {
              //       $scope.AllPrice.push(($scope.orderdetaildata.CommodityInfos[i].Price-$scope.orderdetaildata.ApplyDiscount-($scope.orderdetaildata.IsFullPayment==1?$scope.orderdetaildata.Provider.FullPaymentDiscount:0)-($scope.orderdetaildata.Provider.IsStandard==true?$scope.orderdetaildata.Provider.NonstandardDiscount:0))*$scope.orderdetaildata.CommodityInfos[i].Weight);
              //       // 往all里添加（单价-单价优惠-非标优惠）* 重量=实际价格        
              //        $scope.sprice+=$scope.AllPrice[i]
              //        // 把每个实际价格相加得到总价
              //   }
                // $scope.sprice-=$scope.orderdetaildata.UnitTotal;
                // 总价-先款非标优惠合计=实际总价；
                console.log($scope.sprice)
            })
            .then(function (error) {
                if (error) {
                    console.log("error");
                }
            });
            //保存修改送货信息
            $scope.savechage=function(){
                $http.post('../api/OrderManager/OrderBaseEdit', $scope.orderdetaildata)
                .success(function (res) {
                    if (res.State <= 0) {
                        alert(res.Msg);
                    } else {
                        alert("更改成功");
                        $scope.readonlytoggel=true;
                    }
                });
            }
         //修改送货信息
        $scope.readonlytoggel=true;
        $scope.ipttoggel=function(){
            $scope.readonlytoggel=false;
        }
        //返回计划单列表
        $scope.goorderList = function () {
            $state.go('app.Order_MyorderList');
        };
        //查看大图
        $scope.editReceipt = function(item){
            $scope.editReceiptdata = item
        };
        //获取收货凭证路径
        $http({
            url:"../api/Order/GetReceipt?orderId="+$scope.id,
            method:"GET"
        })
                .then(function (res) {
//                            console.log(res.data.Data);
                    if (res.data.Data.length > 0){
                        $scope.GetReceiptdata = res.data.Data;
                        console.log($scope.GetReceiptdata);
                    }else{
                        console.log("meishuju")
                    }
                })
                .then(function (error) {
                    if(error){
                        console.log("error");
                    }
                });
        $scope.GetReceiptdata = false;
        //取消计划单
        $scope.cancel = function () {
            $http({
                url: "../api/Order/Cancel?id=" + $scope.id,
                method: "POST"
            })
                .then(function () {
                    alert("已提交");
                    $state.go('app.Order_MyorderList');
                })
                .then(function (error) {
                    if (error) {
                        console.log("error");
                    }
                });
        };
        //退货
        $scope.refunds = function () {
            $http({
                url: "api/Order/ReturnGoods?id=" + $scope.id,
                method: "POST"
            })
                .then(function () {
                    alert("已提交");
                    $state.go('app.Order_MyorderList');
                })
                .then(function (error) {
                    if (error) {
                        console.log("error");
                    }
                });
        };
        $scope.refer = function () {
            $http.post('../api/OrderManager/OrderBaseEdit', $scope.orderdetaildata)
                .success(function (res) {
                    if (res.State <= 0) {
                        alert(res.Msg);
                    } else {
                        alert("更改成功");
                        $state.go("app.Order_MyorderList");
                    }
                });
        };
        $scope.printPact = function(){
            window.open("../Print/SalesContract?orderId=" + $scope.id);
        };
        $scope.printPactMW = function () {
            window.open("../Print/SalesContractMW?orderId=" + $scope.id);
        }; 
        $scope.printOut = function(){
            window.open("../Print/StockOut?orderId=" + $scope.id);
        };
        $scope.add = function () {
            if($scope.orderdetaildata.Account.IsCash == true){
                if ($scope.NowData.Remark == undefined) {
                    return alert('私户付款，请备注打卡账号后四位')
                }else if ($scope.NowData.Remark.length < 4) {
                     return alert('私户付款，请备注打卡账号后四位')
                }
            }
           
            $scope.NowData.Customer.ShortName = $scope.orderdetaildata.Customer.ShortName;
            $scope.NowData.AccountId = $scope.orderdetaildata.Account.Id;
            $http.post("../api/ClientManager/ApplyPaymentInfo", $scope.NowData)
                    .then(function (res) {
                        if (res.State <= 0) {
                            alert(res.Msg);
                        } else {
                            alert("提交成功");
                            $('#baokuan').modal("hide");
                        }
                    },function (error) {
                        if (error) {
                            alert("失败");
                        }
                    });
        };
        $scope.bar = $(".bar");//进度条
        $scope.percent = $('.percent');//获取上传百分比
        $scope.showimg = $('.showimg');//显示图片的div
        $scope.progress = $('.progress');//显示进度的div
        $scope.files = $('.files');//文件上传控件的input元素
        $scope.btn = $('.btn span'); //按钮文本
        $scope.gosubmit2 = function (){
            $("#myupload").ajaxSubmit({
                dataType :'json',//返回数据类型
                beforeSend:function(){
                    $scope.showimg.empty();
                    $scope.progress.show();
                    $scope.percentVal = '0%';
                    $scope.bar.width($scope.percentVal);
                    $scope.percent.html($scope.percentVal);
                    $scope.btn.html('上传中..');
                },
                //更新进度条事件处理代码
                uploadProgress:function(event,position,total,percentComplete){
                    $scope.percentVal = percentComplete + '%';
                    $scope.bar.width($scope.percentVal);
                    $scope.percent.html($scope.percentVal);
                },
                success:function(data){//图片上传成功时
                    if(data){
                        alert("上传成功");
                        $('#shangchuan').modal("hide");
                        $state.go('app.FieldMan_FieldManDetail', {
                            orderid: JSON.stringify($scope.id)
                        });
                    }
                },
                error:function(xhr){
                    $('#shangchuan').modal("hide");
                    alert("上传失败");
//                    $scope.btn.html('上传失败');
//                    $scope.bar.width('0');
//                    $scope.files.html(xhr.responseText);
                }
            });
        };
    })
</script>